import {Hero} from '../hero';
import {HeroService} from '../hero.service';
import {HEROES} from '../mock-heroes';
import {Component, OnInit} from '@angular/core';
import {HeritageClause} from 'typescript';

@Component({
  selector: 'app-heroes',
  templateUrl: './heroes.component.html',
  styleUrls: ['./heroes.component.css']
})
export class HeroesComponent implements OnInit {

  heroes: Hero[];

  selectedHero: Hero;

  constructor(private heroService: HeroService) {
  }

  ngOnInit() {
    this.getHeros();
  }

  onSelect(hero: Hero): void {
    this.selectedHero = hero;
  }

  getHeros(): void {
    this.heroService.getHeros().subscribe(heros => this.heroes = heros);
  }
}
